package com.project.service.impl;

import com.project.service.ICountry;
import com.project.service.IManService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

@Service
public class ManServiceImpl implements IManService {
//    @Autowired //按类型匹配的方式，注入已注册的spring组件。该类只有一个实现类
//    @Qualifier("cn")
    @Resource(name = "us")
    private ICountry country;
    @Value("${name}") //将属性文件中，name键对应的值就当做当前属性
    private String name;

    @PostConstruct //创建spring组件时触发
    public void init(){
        System.out.println("初始化方式");
    }

    @PreDestroy  //容器关闭销毁spring组件时触发
    public void del(){
        System.out.println("销毁方式");
    }

    @Override
    public void run() {
        System.out.println("傻孩子们，快跑呀！" + name);
        country.build();
    }
}
